DECLARE @intMonth INT
SET @intMonth = 1
declare @sMonth nvarchar(20)
declare @sql nvarchar(max)
WHILE @intMonth <=6
BEGIN
	
	set @sMonth= CAST(@intMonth as nvarchar(20))

	set @sql=N'update a
	set a.[month'+@sMonth+'] =(CASE WHEN b.pro_auto is null  THEN ''N''
		  WHEN b.pro_auto =1 THEN ''Y''
			ELSE str(b.pro_auto, 25,0)  END)
	from TBL_ACCOUNT_PLANNING_PRODUCT_HOLDING_RESULT as a, [TBL_CUSTOMER_PRODUCT_HOLDING_20160'+@sMonth+'] as b
	where a.cif=b.recid and a.name like N''%Sản phẩm Ô tô%'''
    print(@sql)
	exec(@sql)
    SET @intMonth = @intMonth + 1
END
GO